{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ec5418f-b395-4f49-a152-f164d86172a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串基础 \n",
    "name = 'jason' \n",
    "city = 'beijing' \n",
    "text = \"welcome to jike shijian \" \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7d9d2e8-ad47-4f81-8d1d-341c1b7890e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = 'hello' \n",
    "s2 = \"hello\" \n",
    "s3 = \"\"\"hello\"\"\" \n",
    "s1 == s2 == s3 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f81be537-1c65-47bf-a2b7-64678470ab48",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = ''\n",
    "for n in range(0,100000):\n",
    "    s += str(n) \n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6cb6f3b0-af31-4816-8cbf-8495194bc0b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "l = [] \n",
    "for n in range(0,100):\n",
    "    l.append(str(n)) \n",
    "l = ' '.join(l)\n",
    "l"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "93981e4e-0423-4d7b-8dba-f05ef111b36e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'my name is Jack'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = ' my name is Jack ' \n",
    "s = s.strip() \n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "452fd537-83a5-4412-b5f2-294b252a26cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "字符优化性能，+=的性能不会每次创建新的字符串"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
